var $;
layui.config({
	base : "js/"
}).use(['form','layer','jquery'],function(){
	var form = layui.form(),
		layer = parent.layer === undefined ? layui.layer : parent.layer,
		laypage = layui.laypage;
		$ = layui.jquery;

 	form.on("submit(addUser)",function(data){
 		var dto = {
 			"supplierName": $(".supplierName").val(),
 			"supplierAdder": $(".supplierAdder").val(),
 			"supplierContacts": $(".supplierContacts").val(),
 			"supplierTel": $(".supplierTel").val(),
 			"remark": $(".remark").val()
 		};
        $.ajax({
	        url: API_URL_HEAD+"supplier/create",
	        type: 'post',
	        contentType: "application/json; charset=utf-8",
	        data: JSON.stringify(dto),
	        dataType: 'json',
	        success: function (data) {
	            if(data.code == 0){
	               //刷新父页面
		 			parent.location.reload();
	            }
	        }
    	});
 		//弹出loading
// 		var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
//      setTimeout(function(){
//          top.layer.close(index);
//			top.layer.msg("供货商添加成功！");
// 			layer.closeAll("iframe");
//	 		//刷新父页面
//	 		parent.location.reload();
//      },2000);
   		return false;
 	})
	
})

//格式化时间
function formatTime(_time){
    var year = _time.getFullYear();
    var month = _time.getMonth()+1<10 ? "0"+(_time.getMonth()+1) : _time.getMonth()+1;
    var day = _time.getDate()<10 ? "0"+_time.getDate() : _time.getDate();
    var hour = _time.getHours()<10 ? "0"+_time.getHours() : _time.getHours();
    var minute = _time.getMinutes()<10 ? "0"+_time.getMinutes() : _time.getMinutes();
    return year+"-"+month+"-"+day+" "+hour+":"+minute;
}
